<template>
  <van-tabs>
    <van-tab title="销量">
      <splist />
    </van-tab>
    <van-tab title="新品">
      <splist :sort="5" />
    </van-tab>
    <van-tab>
      <template #title>
        <div>
          <div class="demo" @click="onClick">
            <div>价格</div>
            <img :src="imgurl" alt />
          </div>
        </div>
      </template>
      <splist :sort="sorts" />
    </van-tab>
  </van-tabs>
</template>
<script>
import splist from "@/components/splist.vue";
export default {
  data() {
    return {
      isok: true,
      sorts: 1,
      imgurl:
        "https://img06.yiguoimg.com/d/web/170830/00911/152542/priceone.png"
    };
  },
  components: {
    splist
  },
  methods: {
    onClick() {
      //控制价格排序的小图标高亮方向
      if (this.isok) {
        this.isok = !this.isok;
        this.sorts = 1;
        this.imgurl =
          "https://img07.yiguoimg.com/d/web/180508/01313/150959/pricethree.png";
      } else {
        this.sorts = 2;
        this.isok = !this.isok;
        this.imgurl =
          "https://img05.yiguoimg.com/d/web/180508/01313/150959/pricetwo.png";
      }
    }
  }
};
</script>
<style lang="scss">
//清除默认地边框
.van-tabs__line {
  height: 0px;
}
.van-tabs {
  .van-tabs__wrap {
    height: 2.56625rem;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 101;
    //所有标签
    .van-tab {
      color: #808080;
      font-size: 0.754375rem;
    }
    .van-tabs__nav {
      height: 2.56625rem;
    }
    .demo {
      //价格排序
      position: absolute;
      top: 0;
      left: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 7.8125rem;
      height: 100%;
      img {
        //小图标
        margin-left: 0.1875rem;
        width: 0.33875rem;
        height: 0.49rem;
      }
    }
  }
}

//选中标签样式
.van-tab--active {
  border-bottom: 2px solid #11b57c;
  color: #11b57c;
  font-weight: 500;
}
</style>